# $Id$
# Maintainer: Giovanni Scafora <giovanni@archlinux.org>
# Maintainer: Zach Bacon <11doctorwhocanada@gmail.com>
# Contributor: Gilles CHAUVIN <gcnweb@gmail.com>

_realname=live-media
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2019.11.06
pkgrel=1
pkgdesc="A set of C++ libraries for multimedia streaming (mingw-w64)"
arch=('any')
license=('LGPL')
url="http://live555.com/liveMedia"
depends=("${MINGW_PACKAGE_PREFIX}-gcc")
options=('staticlibs')
source=("https://download.videolan.org/contrib/live555/live.${pkgver}.tar.gz")
sha256sums=('a512071d1c6dd2caf16ecec0aa2c24f0b1cc4fe789e96adc927ee1fe29be493a')

build() {
  cd ${srcdir}/live
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p "${srcdir}"/build-${CARCH} && cd "${srcdir}"/build-${CARCH}
  cp -rf ${srcdir}/live/* "${srcdir}"/build-${CARCH}
  ./genMakefiles mingw

  make CC=gcc
}

package() {
  cd "${srcdir}"/build-${CARCH}

  for dir in BasicUsageEnvironment groupsock liveMedia UsageEnvironment; do
    install -dm755 ${pkgdir}${MINGW_PREFIX}/{bin,lib,include/${dir}}
    install -m644 ${dir}/*.a "${pkgdir}${MINGW_PREFIX}/lib"
    install -m644 ${dir}/include/*.h* "${pkgdir}${MINGW_PREFIX}/include/${dir}"
  done

  for testprog in `find testProgs -type f -perm 755`; do
    install ${testprog} "${pkgdir}${MINGW_PREFIX}/bin"
  done
}
